#!/bin/bash

AA="1111"
BB="2222"
${AA-${BB}} => 1111

BB="2222"
${AA-${BB}} => 2222

echo disabled > /sys/bus/usb/devices/2-1/power/wakeup
echo on > /sys/bus/usb/devices/2-1/power/control

$LINENO

[[ "$1" == -* ]] && echo OK

AA=1234567890
${AA:8:1} => 9
${AA:8:2} => 90

AA="11.zip.22.zip"
${AA/.zip/-sign.zip} => 11-sign.zip.22.zip
${AA//.zip/-sign.zip} => 11-sign.zip.22-sign.zip

FILE_NAME="11/22/33/44/55/66"
${FILE_NAME##*/} => 66
${FILE_NAME#*/} => 22/33/44/55/66
${FILE_NAME%%/*} => 11
${FILE_NAME%/*} => 11/22/33/44/55

AA="123456"
${#AA} => 6 -- length of AA

ARRAY=(11 22 33 44 55)
${#ARRAY[@]} => 5 -- element count of ARRAY
${#ARRAY[0]} => 2 -- length of ARRAY[0]

for ((i = 0; i < 10; i++))
do
	echo $i
done

set # 查看所有的函数
env # 查看所有的环境变量
apt-get purge bash # 卸载
apt-cache show bash
apt-get -f install

function test-func1 # 查看当前函数名及调用关系
{
	echo "FUNCNAME = ${FUNCNAME}: ${FUNCNAME[@]}"
}

function test-func2 # 查看当前函数名及调用关系
{
	test-func1

	echo "FUNCNAME = ${FUNCNAME}: ${FUNCNAME[@]}"
}

test-func2

echo "BASH_SOURCE = ${BASH_SOURCE}"
echo "\$0 = $0"

if [ -n "$BASH_SOURCE" -a "$BASH_SOURCE" != "$0" ]
then
	echo "The script is sourced by another script"
else
	echo "Run directly in the shell"
fi

算术运算有四种方式:
1. AA=$(expr 4 + 5)
2. AA=$((4 + 5))
3. AA=$[4 + 5]
4. let AA="4+5"

shotmount -e 192.168.1.19 # 查看nfs导出列表
